package com.android.phoenix.activity.discovery;

import java.util.ArrayList;
import java.util.List;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.android.phoenix.Constant;
import com.android.phoenix.R;
import com.android.phoenix.activity.BaseActivity;

public class RankDetailActivity extends BaseActivity{
	
	private TextView tvTabRankDetailName;
	private ListView listDistance;
	private List<String> mList = new ArrayList<String>();
	private BaseAdapter mAdapter;
	private ImageView imgBack;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.acti_rank_detail);
		Intent intent = getIntent();
		
		tvTabRankDetailName = (TextView) findViewById(R.id.tvTabRankDetailName);
		tvTabRankDetailName.setText(intent.getStringExtra(Constant.RANK_NAME).toString());
		
		imgBack = (ImageView) findViewById(R.id.imgBack);
		imgBack.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				finish();
			}
		});
		
		listDistance = (ListView) findViewById(R.id.listDistance);
		mAdapter = new DistanceAdapter();
		listDistance.setAdapter(mAdapter);
		
		mList.add("李四");
		mList.add("张三");
		mList.add("王二");
		mList.add("小红");
		mList.add("小李");
		mList.add("小明");
		
		
	}
	
	private class DistanceAdapter extends BaseAdapter{

		@Override
		public int getCount() {
			return mList.size();
		}

		@Override
		public Object getItem(int position) {
			return mList.get(position);
		}

		@Override
		public long getItemId(int position) {
			return position;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			convertView = LayoutInflater.from(RankDetailActivity.this).inflate(R.layout.acti_rank_detail_item,null);
			TextView tvRank = (TextView)convertView.findViewById(R.id.tvRank);
			tvRank.setText(String.valueOf(position + 1));
			TextView tvRankName = (TextView)convertView.findViewById(R.id.tvRankName);
			tvRankName.setText(mList.get(position));
			TextView tvDistance = (TextView)convertView.findViewById(R.id.tvDistance);
			tvDistance.setText("111111111" + "米");
			return convertView;
		}
		
	}

}
